#include <iostream>
#include <memory>
class Burger
{
    public:
        virtual void cook()=0;
        virtual ~Burger(){}
};
class BeefBurger: public Burger
{
    public:
        BeefBurger(){
        }
        virtual void cook()override{
            std::cout<<"Preparing beef burgers..."<<std::endl;
        }
    private:
        int _beef;
};

class ChickenBurger: public Burger
{
    public:
        ChickenBurger(){
        }
        virtual void cook()override{
            std::cout<<"Preparing chicken burgers..."<<std::endl;
        }
    private:
        int _chicken;
};

class Restaurant
{
    public:
        Burger *order(){
            return create();
        }
    private:
        virtual Burger *create() = 0;
};

class BeefRestaurant :public Restaurant
{
    public:
        virtual Burger *create() override
        {
            Burger* burger = new BeefBurger();
            burger->cook();
            return burger;
        }
};

class ChickenRestaurant :public Restaurant
{
    public:
        virtual Burger *create() override
        {
            Burger* burger = new ChickenBurger();
            burger->cook();
            return burger;
        }
};
void produceBurger(std::shared_ptr<Restaurant> rest){
    rest->order();
}
// 缺点： 一个餐厅只能生产一种食物
int main()
{
    std::shared_ptr<Restaurant> brest = std::make_shared<BeefRestaurant>();
    std::shared_ptr<Restaurant> crest = std::make_shared<ChickenRestaurant>();
    produceBurger(brest);
    produceBurger(crest);
    return 0;
}

